package com.goodwill.androidtest.systime;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class SysTime {
    public static String serverTime = "2019-08-21 17:12:43";

    public static void main(String[] args) {
        try {
            SimpleDateFormat sdfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = sdfDateFormat.parse(serverTime);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH) + 1;
            int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
            int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY);
            int minute = calendar.get(Calendar.MINUTE);
            System.out.println("syear: " + year);
            System.out.println("smonth: " + month);
            System.out.println("sday: " + dayOfMonth);
            System.out.println("shour: " + hourOfDay);
            System.out.println("sminute: " + minute);

//            System.out.println(calendar.get(Calendar.MONTH) + 1);
//            System.out.println(calendar.get(Calendar.DAY_OF_MONTH));


//            System.out.println("syear: " + date.getYear());
//            System.out.println("smonth: " + date.getMonth());
//            System.out.println("sday: " + date.getDay());
//            System.out.println("shour: " + date.getHours());
//            System.out.println("sminute: " + date.getMinutes());

//            Calendar calendar= Calendar.getInstance();
//            SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            System.out.println(dateFormat.format(calendar.getTime()));

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
